import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';

enum Api {
  list = '/system-service/onlineUser/page',
  forceLogout='/system-service/onlineUser/forceLogout',
  forceLogoutBatch='/system-service/onlineUser/forceLogoutBatch',
  importExcel = '/system-service/user/importExcel',
  exportXls = '/system-service/user/exportXls',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) => 
  defHttp.get({url: Api.list, params});

/**
 * 删除用户
 */
export const forceLogout = (params, handleSuccess) => {
  return defHttp.delete({url: Api.forceLogout, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除用户
 * @param params
 */
export const forceLogoutBatch = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认强退',
    content: '是否强退选中用户',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.forceLogoutBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
